package tpo.wmb.provider.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import pojo.Useraddress;

import java.util.List;
import java.util.Map;

@Repository
//客户地址
public interface UserAddressMapper {

    /**
     * 查询客户所有收货地址
     */
    @Select("SELECT *  FROM useraddress  WHERE user = #{uid} and deleteState = 1")
    List<Useraddress> selectAddressList(Integer uid);


    /**
     * id查询地址
     */
    @Select("select * from useraddress where id = #{id}")
    Useraddress selectAddress( Integer id);


    /**
     * 新增地址
     */
    @Insert("insert into useraddress (address,user,man,sj,dh,dq) values(#{address},#{user},#{man},#{sj},#{dh},#{dq})")
    Integer insertAddress( Useraddress useraddress);


    /**
     * 修改地址
     */
    @Update("update useraddress set address = #{address},user=#{user},man=#{man},sj=#{sj},dh=#{dh},dq=#{dq} where id = #{id}")
    Integer updateAddress( Useraddress useraddress);


    /**
     * 删除地址
     */
    @Insert("update useraddress set deleteState = 0 where id = #{id}")
    Integer deleteAddress( Integer id);


    /**
     * 查询用户的默认地址
     */
    @Select("select * from useraddress where user = #{uid} and defaultState = 1")
    Useraddress selectDefalutAddress( Integer uid);

}
